package com.loan.service;
import java.util.Arrays;
import java.util.Map;

import com.jfinal.plugin.activerecord.Page;
import com.loan.model.Version;

public class VersionService extends BaseService<Version>{

	/**
	 * 检查是否有新版本 
	 */
	public static Version checkVersion(String system, String type, String code) {
		return Version.dao.findFirst("select * from version where system=? and type=? and code>?", system, type, code);
	}	
	
	/** 
	 * 分页信息
	 * @return
	 */
	public Page<Version> list(int page, int size, Map<String, String> map) {
		return Version.dao.paginate(page, size, buildSql("version",Arrays.asList("name"),map));
	}

	public Version lastVersion() {
		return Version.dao.findFirst("select * from version where system='android' order by code desc ");
	}
}
